Skip to content

Update generated formulas to follow the new naming scheme - #350

Merged
shsms merged 14 commits into
frequenz-floss:v0.x.xfrom
sahas-subramanian-frequenz:new-power-formulas
May 15, 2023
Merged

Update generated formulas to follow the new naming scheme#350
shsms merged 14 commits into
frequenz-floss:v0.x.xfrom
sahas-subramanian-frequenz:new-power-formulas

Conversation

@sahas-subramanian-frequenz

@sahas-subramanian-frequenz sahas-subramanian-frequenz commented Apr 20, 2023

Copy link
Copy Markdown
Contributor

New power streaming methods - public api

  • BatteryPool.{production_power, consumption_power}
  • EVChargerPool.{production_power, consumption_power}
  • LogicalMeter:
    • consumer_power
    • grid_production_power
    • grid_consumption_power
    • chp_power
    • chp_production_power
    • chp_consumption_power (probably not necessary, but having just a production method was a bit weird)

New FormulaEngine steps - internal

  • ConstantValue - for multiplying formula outputs with -1 to get production power.
  • Clipper - for clipping formula outputs to 0.0 in production/consumption power formulas.

New component graph methods - internal

  • is_pv_inverter, is_pv_meter, is_pv_chain
  • is_battery_inverter, is_battery_meter, is_battery_chain
  • is_ev_charger, is_ev_charger_meter, is_ev_charger_chain,
  • is_chp, is_chp_meter, is_chp_chain

These methods were particularly useful in the creation of the consumer_power formula.

The *chain methods return true if either of the other corresponding methods return true. Maybe there's a better name, but it is for internal use.

@sahas-subramanian-frequenz
sahas-subramanian-frequenz requested a review from a team as a code owner April 20, 2023 10:53
@github-actions github-actions Bot added part:actor Affects an actor ot the actors utilities (decorator, etc.) part:config Affects the configuration management part:data-pipeline Affects the data pipeline part:docs Affects the documentation part:microgrid Affects the interactions with the microgrid part:tests Affects the unit, integration and performance (benchmarks) tests labels Apr 20, 2023
@sahas-subramanian-frequenz
sahas-subramanian-frequenz marked this pull request as draft April 20, 2023 10:53
@sahas-subramanian-frequenz
sahas-subramanian-frequenz force-pushed the new-power-formulas branch 2 times, most recently from fd75584 to 068f61b Compare April 24, 2023 16:03
@github-actions github-actions Bot removed part:actor Affects an actor ot the actors utilities (decorator, etc.) part:docs Affects the documentation part:config Affects the configuration management labels Apr 24, 2023
@sahas-subramanian-frequenz

Copy link
Copy Markdown
Contributor Author

Need to add tests for the consumer_power formula, will be ready tomorrow.

@sahas-subramanian-frequenz
sahas-subramanian-frequenz force-pushed the new-power-formulas branch 4 times, most recently from fa71205 to f6fb8cb Compare April 25, 2023 15:07
@sahas-subramanian-frequenz sahas-subramanian-frequenz added this to the v0.21.0 milestone Apr 25, 2023
@sahas-subramanian-frequenz
sahas-subramanian-frequenz marked this pull request as ready for review April 25, 2023 15:56
@sahas-subramanian-frequenz sahas-subramanian-frequenz linked an issue Apr 25, 2023 that may be closed by this pull request

@cwasicki cwasicki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some high-level comments. Most importantly I think the methods for solar are missing.

Comment thread src/frequenz/sdk/timeseries/_formula_engine/_formula_steps.py Outdated
Comment thread src/frequenz/sdk/timeseries/logical_meter/_logical_meter.py
Comment thread src/frequenz/sdk/timeseries/ev_charger_pool/_ev_charger_pool.py Outdated
Comment thread src/frequenz/sdk/timeseries/ev_charger_pool/_ev_charger_pool.py Outdated
Comment thread src/frequenz/sdk/microgrid/_graph.py
Comment thread src/frequenz/sdk/timeseries/logical_meter/_logical_meter.py
@sahas-subramanian-frequenz
sahas-subramanian-frequenz force-pushed the new-power-formulas branch 3 times, most recently from 3c8d3c1 to 21e6e6a Compare May 2, 2023 10:22
@sahas-subramanian-frequenz

Copy link
Copy Markdown
Contributor Author

Rebased on latest.

@matthias-wende-frequenz matthias-wende-frequenz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost finished. I've a couple of open question w.r.t. the consumer power. No questions. I missed the continue in the loop over the successors :).

f"{meter.category}. Expected ComponentCategory.METER."
)
meter_successors = component_graph.successors(meter.component_id)
if len(meter_successors) != 1:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that check necessary? Seems to me that we would disallow a valid grid topology, where one meter is measuring more then 1 CHPs?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, updated.


@abstractmethod
def is_battery_chain(self, component: Component) -> bool:
"""Check if the specified component is part of a battery chain.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to use the docs to define what a battery chain is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


@abstractmethod
def is_ev_charger_chain(self, component: Component) -> bool:
"""Check if the specified component is part of an EV charger chain.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


@abstractmethod
def is_chp_chain(self, component: Component) -> bool:
"""Check if the specified component is part of a CHP chain.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

return self._gen_with_grid_meter(builder, grid_meter)
return self._gen_without_grid_meter(builder, grid_successors)

def _gen_with_grid_meter(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be careful here since this stops working once we add sub panels (Unterverteilungen) into the microgrid api. Maybe it's worth adding a comment here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to introduce sub panels into the component graph? I haven't heard of any such plans. Those are passive components right? i.e we can't read from them or control them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I remember that was the plan. @tiyash-basu-frequenz can you confirm?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to add a short warning comment to the documentation such that we are aware in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a comment:

If the component graph supports additional types of grid successors in the future, additional checks need to be added here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the term "sub panels" is misleading. If I have understood it correctly, then it is a section of the microgrid behind a dedicated fuse. I'd call it sub-section.

But I'd suggest ignoring it for now. It is not scheduled to be added to the microgrid API soon. To me even a comment seems unnecessary: because it does not improve the readability and just hints at a future functionality without knowing when we will add it. But up to you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you really want to track this feature, then creating an issue is the proper way to do it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right w.r.t. the issue. We should create one but I'd also leave a comment just to have the behavior documented because it tells that the algorithm isn't going into the depth.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I'd suggest to rather create the issue and add a link to the issue in the comment.

I'd suggest doing it in moderation, if never at all, because you do not want to end up adding every proposed feature in the comments.

@sahas-subramanian-frequenz
sahas-subramanian-frequenz force-pushed the new-power-formulas branch 2 times, most recently from 13e7fe1 to 7c30e4c Compare May 9, 2023 15:33
shsms added 10 commits May 15, 2023 12:03
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
This is useful for switching the sign of values, by multiplying by -1,
for example.

Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>

@matthias-wende-frequenz matthias-wende-frequenz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved apart from my last comment.

shsms added 4 commits May 15, 2023 17:15
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
The battery power formula has been moved to the battery pool, and is
being tested there.

And a new test for the new PV Power methods was added in the previous
commit.

Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
Signed-off-by: Sahas Subramanian <sahas.subramanian@frequenz.com>
@shsms
shsms added this pull request to the merge queue May 15, 2023
Merged via the queue into frequenz-floss:v0.x.x with commit 3edf6a5 May 15, 2023
@sahas-subramanian-frequenz
sahas-subramanian-frequenz deleted the new-power-formulas branch May 16, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

part:data-pipeline Affects the data pipeline part:microgrid Affects the interactions with the microgrid part:tests Affects the unit, integration and performance (benchmarks) tests

Projects

Development

Successfully merging this pull request may close these issues.

Update generated formulas to use new naming scheme

5 participants